package com.ruoyi.xdata.domain;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.utils.DateUtils;

import lombok.Getter;
import lombok.Setter;

/**
 * 接口数据对象 
 * 
 * @author yepanpan
 * @date 2020-12-29
 */
@Getter
@Setter
public class XdataVo extends BaseEntity {

	private String table;

	private String id;

	private String token;
		
	//@ApiModelProperty("操作类型:insert|update|delete|query")
	//private String action;

	private Map<String, Object> data;

	private List<Map<String, Object>> rows;
	
	private Integer offset;
	private Integer limit;
	
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	private Date last;
	
	/**
	 * 转换成URL参数
	 * @return
	 */
	public String toUrl() {
		String ret = "";
		if(this.table != null) ret += "&table="+this.table;
		if(this.token != null) ret += "&token="+this.token;
		if(this.offset != null) ret += "&offset="+this.offset;
		if(this.limit != null) ret += "&limit="+this.limit;
		if(this.last != null) ret += "&last="+DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, last);
		return ret.substring(1);
	}
}
